package process;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;

import abstractclass.AbstractProcess;
import freemarker.template.Template;

public class ServiceImplProcess extends AbstractProcess{

	@Override
	public void processJava(String packgerOutPath, String beanName, String path, Object object) {
		if(path==null){
			throw new NullPointerException("path is null");
		}
		path = path+"service"+File.separator;
		File file = new File(path);
		if(!file.exists()){
			file.mkdirs();
		}
		try 
        {
			Template template = configuration.getTemplate(ftlFilePrefix+"service.ftl");
           
			Map<String, Object> ParamMap = new HashMap<String, Object>();
            ParamMap.put("packageOutPath", packgerOutPath);
            ParamMap.put("bean", beanName);

            Writer writer  = new OutputStreamWriter(new FileOutputStream(path+beanName+"Service.java"),"UTF-8"); 
            template.process(ParamMap, writer);  

			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	
}
